import { NestFactory } from "@nestjs/core";
import { NestExpressApplication } from "@nestjs/platform-express";
import { AppModule } from "./app.module";
import { ValidationPipe } from "./pipe/validation.pipe";
import * as serveStatic from "serve-static";
import * as path from "path";
// import path from "node:path";

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.enableCors();

  app.use(
    "/public",
    serveStatic(path.join(__dirname, "../public"), {
      maxAge: "1d",
      extensions: ["jpg", "jpeg", "png", "gif"],
    })
  );
  app.useGlobalPipes(new ValidationPipe());
  await app.listen(8000);
}
bootstrap();
